home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmDice
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "The Dice Program"
- ClientHeight = 4515
- ClientLeft = 990
- ClientTop = 1695
- ClientWidth = 6720
- Height = 5205
- Icon = "DICE.frx":0000
- Left = 930
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 4515
- ScaleWidth = 6720
- Top = 1065
- Width = 6840
- Begin VB.CommandButton cmdChangeBackground
- Caption = "&Change Background Color"
- Height = 495
- Left = 2160
- TabIndex = 7
- Top = 3960
- Width = 2415
- End
- Begin VB.HScrollBar hsbGuess
- Height = 255
- Left = 2160
- Max = 12
- Min = 2
- TabIndex = 5
- Top = 3600
- Value = 7
- Width = 2415
- End
- Begin VB.Timer Timer1
- Interval = 50
- Left = 0
- Top = 720
- End
- Begin VB.Line linBackDoor
- Visible = 0 'False
- X1 = 6600
- X2 = 6660
- Y1 = 60
- Y2 = 0
- End
- Begin VB.Label lblGuessValue
- Caption = "7"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 13.5
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 3960
- TabIndex = 6
- Top = 3120
- Width = 495
- End
- Begin VB.Label lblYourGuess
- Caption = "Your Guess:"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 13.5
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 2160
- TabIndex = 4
- Top = 3120
- Width = 1695
- End
- Begin VB.Label lblGameResult
- Alignment = 2 'Center
- Caption = "To roll the dice, click any of the dice"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 24
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 1215
- Left = 840
- TabIndex = 3
- Top = 120
- Width = 4935
- End
- Begin TegoswLibCtl.Tegosw swExit
- Height = 630
- Left = 0
- TabIndex = 2
- Top = 0
- Width = 525
- _version = 65536
- _extentx = 926
- _extenty = 1111
- _stockprops = 64
- value = -1 'True
- End
- Begin TegdiceLibCtl.TegoDice TegoDice2
- Height = 1545
- Left = 5280
- TabIndex = 1
- Top = 1560
- Width = 1290
- _version = 65536
- _extentx = 2275
- _extenty = 2725
- _stockprops = 65
- picture1 = "DICE.frx":030A
- picture2 = "DICE.frx":0326
- picture3 = "DICE.frx":0342
- picture4 = "DICE.frx":035E
- picture5 = "DICE.frx":037A
- picture6 = "DICE.frx":0396
- End
- Begin TegdiceLibCtl.TegoDice TegoDice1
- Height = 1545
- Left = 120
- TabIndex = 0
- Top = 1560
- Width = 1290
- _version = 65536
- _extentx = 2275
- _extenty = 2725
- _stockprops = 65
- autosize = -1 'True
- picture1 = "DICE.frx":03B2
- picture2 = "DICE.frx":03CE
- picture3 = "DICE.frx":03EA
- picture4 = "DICE.frx":0406
- picture5 = "DICE.frx":0422
- picture6 = "DICE.frx":043E
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuExit
- Caption = "E&xit"
- End
- End
- Begin VB.Menu mnuHelp
- Caption = "&Help"
- Begin VB.Menu mnuAbout
- Caption = "About..."
- End
- End
- Attribute VB_Name = "frmDice"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- ' All variables must be declared.
- Option Explicit
- ' The Rolling In Progress flag.
- Dim gRollingInProgress
- Private Sub cmdChangeBackground_Click()
- Static Background
- ' Increment the Background static variable
- Background = Background + 1
- ' If Background is greater than 15, reset it to 1.
- If Background > 15 Then Background = 1
- ' Change the color of the form according to the
- ' current value of Background.
- Me.BackColor = QBColor(Background)
- ' Change the background color of the two dice
- ' controls and the three label controls to the
- ' new color of the form.
- TegoDice1.BackColor = Me.BackColor
- TegoDice2.BackColor = Me.BackColor
- lblGameResult.BackColor = Me.BackColor
- lblYourGuess.BackColor = Me.BackColor
- lblGuessValue.BackColor = Me.BackColor
- End Sub
- Private Sub Form_DblClick()
- ' Toggle the Visible property of
- ' the linBackDoor line.
- linBackDoor.Visible = Not linBackDoor.Visible
- End Sub
- Private Sub Form_Load()
- ' Reset the gRollingInProgress flag to False.
- gRollingInProgress = False
- End Sub
- Private Sub hsbGuess_Change()
- ' Set the lblGuessValue label to the value
- ' of the hsbGuess scrollbar.
- lblGuessValue.Caption = Str(hsbGuess.Value)
- End Sub
- Private Sub lblGameResult_DblClick()
- ' Toggle the Visible property of
- ' the linBackDoor line.
- linBackDoor.Visible = Not linBackDoor.Visible
- End Sub
- Private Sub mnuAbout_Click()
- Dim Title
- Dim Msg
- Dim CR
- CR = Chr(13) + Chr(10)
- ' The title of the About message box.
- Title = "About the Dice Program"
- ' Prepare the message of the About message box.
- Msg = "This program was written with Visual "
- Msg = Msg + "Basic for Windows, using the "
- Msg = Msg + "TegoSoft Dice OCX control. "
- Msg = Msg + CR + CR
- Msg = Msg + "The TegoSoft Dice OCX control "
- Msg = Msg + "is part of the TegoSoft OCX Control "
- Msg = Msg + "Kit - a collection of various OCX controls. "
- Msg = Msg + CR + CR
- Msg = Msg + "For more information about the "
- Msg = Msg + "TegoSoft OCX Control Kit, contact TegoSoft "
- Msg = Msg + "at:"
- Msg = Msg + CR + CR
- Msg = Msg + "TegoSoft Inc." + CR
- Msg = Msg + "P.O. Box 389" + CR
- Msg = Msg + "Bellmore, NY 11710"
- Msg = Msg + CR + CR
- Msg = Msg + "Phone: (516)783-4824"
- ' Display the About message box.
- MsgBox Msg, vbInformation, Title
- End Sub
- Private Sub mnuExit_Click()
- ' Terminate the program
- Unload Me
- End Sub
- Private Sub swExit_Click()
- Dim Title
- Dim Question
- Dim Response
- ' If the user turned the swExit switch OFF,
- ' confirm that the user wants to exit the
- ' program, and if so, exit the program.
- If swExit.Value = False Then
- Title = "Exit Program"
- Question = "Are you sure you want to exit?"
- Response = MsgBox(Question, vbYesNo + vbQuestion, Title)
- If Response = vbYes Then
- Unload Me
- Else
- swExit.Value = True
- End If
- End If
- End Sub
- Private Sub TegoDice1_ClickImage(ByVal Transparent As Boolean)
- ' If the user clicked a solid section of the
- ' dice, start rolling the dice.
- If Transparent = False Then
- ' Place the TegoDice1 dice control on the
- ' right side of the form.
- TegoDice1.Left = 120
-
- ' Place the TegoDice1 dice control on the
- ' left side of the form.
- TegoDice2.Left = 5280
- ' Update the lblGameResult label.
- lblGameResult = "Rolling the dice..."
-
- ' Set the gRollingInProgress flag to True.
- gRollingInProgress = True
- End If
- End Sub
- Private Sub TegoDice2_ClickImage(ByVal Transparent As Boolean)
- ' Execute the TegoDice1_ClickImage() procedure.
- TegoDice1_ClickImage (Transparent)
- End Sub
- Private Sub Timer1_Timer()
- ' If the gRollingInProgress flag is False,
- ' terminate this procedure.
- If gRollingInProgress = False Then Exit Sub
- ' Increment the Value of the two dice controls.
- TegoDice1.Value = TegoDice1.Value + 1
- TegoDice2.Value = TegoDice2.Value + 1
- ' Move the TegoDice1 dice control to the right by 90 twips.
- TegoDice1.MoveImage TegoDice1.Left + 90, _
- TegoDice1.Top, _
- TegoDice1.Width, _
- TegoDice1.Height
- ' Move the TegoDice2 dice control to the right by 90 twips.
- TegoDice2.MoveImage TegoDice2.Left - 90, _
- TegoDice2.Top, _
- TegoDice2.Width, _
- TegoDice2.Height
- ' If the TegoDice1 dice control has reached the
- ' middle of the form, stop the rolling and display
- ' the results of the game.
- If TegoDice1.Left >= 2000 Then
- ' Reset the gRollingInProgress flag to False.
- gRollingInProgress = False
- ' Set the values of the TegoDice1 and TegoDice2
- ' dice controls to random values.
- TegoDice1.RandomDice
- TegoDice2.RandomDice
- ' If the "Back Door" line is visible,
- ' make the user a winner.
- If linBackDoor.Visible = True Then
- TegoDice1.Value = hsbGuess.Value / 2
- TegoDice2.Value = hsbGuess.Value - TegoDice1.Value
- End If
- ' If the sum of the two dice values is the same as the
- ' user's guess, tell the user he/she won. Otherwise,
- ' tell the user he/she lost.
- If hsbGuess.Value = TegoDice1.Value + TegoDice2.Value Then
- lblGameResult.Caption = "You won! Congratulations!!!"
- Else
- lblGameResult.Caption = "You lost. Please try again."
- End If
- End If
- End Sub
-